<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <button id="sub">点击添加事件订阅</button>
  <button id="publish">点击发布事件</button>
  <button id="unsub">取消订阅</button>
  <script src="../../dist/pubsub/index.js"></script>
  <script>
    var EventEmitter = Thanos.default;
    var emitter = new EventEmitter();
    var oSub = document.querySelector('#sub');
    var oPub = document.querySelector('#publish');
    var oUnSub = document.querySelector('#unsub');

    sub.onclick = function() {
      // 绑定两个不同事件, 只取消单个
      emitter.on('triggerEvent', triggerFunc)
      emitter.on('triggerEvent', triggerFunc_1)
      emitter.on('haha', triggerFunc_1)
    }
    oPub.onclick = function() {
      emitter.emit('triggerEvent', {a: 'sdsdfsdf'})
      emitter.emit('haha')
    }
    oUnSub.onclick = function() {
      // emitter.off('triggerEvent');
      emitter.off('triggerEvent', triggerFunc_1);
      // emitter.off('triggerEvent', triggerFunc);
    }

    function triggerFunc(data) {
      console.log(data);
    }
    function triggerFunc_1(data) {
      console.log(emitter)
    }
  </script>
</body>
</html>